1 /*global jQuery:true, GCN: true */ 2 (function (GCN) { 3 4 'use strict'; 5 6 /** 7 * Checks whether or not a tag container instance has data for a tag of the 8 * given name. 9 * 10 * @param {TagContainerAPI} container The container in which to look 11 * for the tag. 12 * @param {string} tagname The name of the tag to find. 13 * @return {boolean} True if the container contains a data for the tag of 14 * the given name. 15 */ 16 function hasTagData(container, tagname) { 17 return !!container._data.tags[tagname]; 18 } 19 20 /** 21 * Extends the internal taglist with data from the given collection of tags. 22 * Will overwrite the data of any tag whose name is matched in the `tags' 23 * associative array. 24 * 25 * @param {TagContainerAPI} container The container in which to look 26 * for the tag. 27 * @param {object} tags Associative array of tag data, mapped against the 28 * data's corresponding tag name. 29 */ 30 function extendTags(container, tags) { 31 jQuery.extend(container._data.tags, tags); 32 } 33 34 /** 35 * Gets the construct matching the given keyword. 36 * 37 * @param {string} keyword Construct keyword. 38 * @param {NodeAPI} node The node inwhich to search for the construct. 39 * @param {function(object)} success Callback function to receive the 40 * successfully found construct. 41 * @param {function(GCNError):boolean} error Optional custom error handler. 42 */ 43 function getConstruct(keyword, node, success, error) { 44 node.constructs(function (constructs) { 45 if (constructs[keyword]) { 46 success(constructs[keyword]); 47 } else { 48 var err = GCN.createError( 49 'CONSTRUCT_NOT_FOUND', 50 'Cannot find construct `' + keyword + '\'', 51 constructs 52 ); 53 GCN.handleError(err, error); 54 } 55 }, error); 56 } 57 58 /** 59 * Creates an new tag via the GCN REST-API. 60 * 61 * @param {TagAPI} tag A representation of the tag which will be created in 62 * the GCN backend. 63 * @param {object} data The request body that will be serialized into json. 64 * @param {function(TagAPI)} success Callback function to receive the 65 * successfully created tag. 66 * @param {function(GCNError):boolean} error Optional custom error handler. 67 */ 68 function newTag(tag, data, success, error) { 69 var obj = tag.parent(); 70 var url = GCN.settings.BACKEND_PATH + '/rest/' + obj._type 71 + '/newtag/' + obj._data.id + GCN._getChannelParameter(obj); 72 obj._authAjax({ 73 type: 'POST', 74 url: url, 75 json: data, 76 error: function (xhr, status, msg) { 77 GCN.handleHttpError(xhr, msg, error); 78 tag._vacate(); 79 }, 80 success: function (response) { 81 obj._handleCreateTagResponse(tag, response, success, 82 error); 83 } 84 }, error); 85 } 86 87 /** 88 * Creates multiple tags via the GCN REST API. 89 * 90 * @param {TagContainerAPI} parent container object for the new tags 91 * @param {object} tagData data object for creating tags. 92 * @param {function(TagAPI)} success Optional success callback 93 * @param {function(GCNError):boolean} error Optional custom error handler. 94 */ 95 function newTags(parent, tagData, success, error) { 96 var url = GCN.settings.BACKEND_PATH + '/rest/' + parent._type 97 + '/newtags/' + parent._data.id + GCN._getChannelParameter(parent); 98 var id, data = {create: {}}; 99 100 for (id in tagData.create) { 101 if (tagData.create.hasOwnProperty(id)) { 102 data.create[id] = tagData.create[id].data; 103 } 104 } 105 106 parent._authAjax({ 107 type: 'POST', 108 url: url, 109 json: data, 110 error: function (xhr, status, msg) { 111 var id; 112 113 GCN.handleHttpError(xhr, msg, error); 114 for (id in tagData.create) { 115 if (tagData.create.hasOwnProperty(id)) { 116 tagData.create[id].tag._vacate(); 117 } 118 } 119 }, 120 success: function (response) { 121 var id; 122 123 if (GCN.getResponseCode(response) === 'OK') { 124 tagData.response = response; 125 for (id in response.created) { 126 if (response.created.hasOwnProperty(id)) { 127 var data = response.created[id].tag, tag = tagData.create[id].tag; 128 tagData.create[id].response = response.created[id]; 129 tag._name = data.name; 130 tag._data = data; 131 tag._fetched = true; 132 133 // The tag's id is still the temporary unique id that was given 134 // to it in _createTag(). We have to realize the tag so that 135 // it gets the correct id. The new id changes its hash, so it 136 // must also be removed and reinserted from the caches. 137 tag._removeFromTempCache(tag); 138 tag._setHash(data.id)._addToCache(); 139 140 // Add this tag into the tag's container `_shadow' object, and 141 // `_tagIdToNameMap hash'. 142 parent._update('tags.' + GCN.escapePropertyName(data.name), 143 data, error, true); 144 145 // TODO: We need to store the tag inside the `_data' object for 146 // now. A change should be made so that when containers are 147 // saved, the data in the `_shadow' object is properly 148 // transfered into the _data object. 149 parent._data.tags[data.name] = data; 150 151 if (!parent.hasOwnProperty('_createdTagIdToNameMap')) { 152 parent._createdTagIdToNameMap = {}; 153 } 154 155 parent._createdTagIdToNameMap[data.id] = data.name; 156 157 tag.prop('active', true); 158 } 159 } 160 161 if (success) { 162 success(); 163 } 164 } else { 165 for (id in tagData) { 166 if (tagData.hasOwnProperty(id)) { 167 tagData[id].tag._die(GCN.getResponseCode(response)); 168 } 169 } 170 GCN.handleResponseError(response, error); 171 } 172 } 173 }, error); 174 } 175 176 /** 177 * Checks whether exactly one of the following combination of options is 178 * provided: 179 * 180 * 1. `keyword' alone 181 * or 182 * 2. `constructId' alone 183 * or 184 * 3. `sourcePageId' and `sourceTagname' together. 185 * 186 * Each of these options are mutually exclusive. 187 * 188 * @param {Object} options 189 * @return {boolean} True if only one combination of the possible options 190 * above is contained in the given options object. 191 */ 192 function isValidCreateTagOptions(options) { 193 // If the sum is 0, it means that no options was specified. 194 // 195 // If the sum is greater than 0 but less than 2, it means that either 196 // `sourcePageId' or `sourceTagname' was specified, but not both as 197 // required. 198 // 199 // If the sum is greater than 2, it means that more than one 200 // combination of settings was provided, which is one too many. 201 return 2 === (options.sourcePageId ? 1 : 0) + 202 (options.sourceTagname ? 1 : 0) + 203 (options.keyword ? 2 : 0) + 204 (options.constructId ? 2 : 0); 205 } 206 207 /** 208 * Parse the arguments passed into createTag() into a normalized object. 209 * 210 * @param {Arguments} createTagArgumenents An Arguments object. 211 * @parma {object} Normalized map of arguments. 212 */ 213 function parseCreateTagArguments(createTagArguments) { 214 var args = Array.prototype.slice.call(createTagArguments); 215 if (0 === args.length) { 216 return { 217 error: '`createtag()\' requires at least one argument. See ' + 218 'documentation.' 219 }; 220 } 221 222 var options; 223 224 // The first argument must either be a string, number or an object. 225 switch (jQuery.type(args[0])) { 226 case 'string': 227 options = {keyword: args[0]}; 228 break; 229 case 'number': 230 options = {constructId: args[0]}; 231 break; 232 case 'object': 233 if (!isValidCreateTagOptions(args[0])) { 234 return { 235 error: 'createTag() requires exactly one of the ' + 236 'following, mutually exclusive, settings to be' + 237 'used: either `keyword\', `constructId\' or a ' + 238 'combination of `sourcePageId\' and ' + 239 '`sourceTagname\'.' 240 }; 241 } 242 options = args[0]; 243 break; 244 default: 245 options = {}; 246 } 247 248 // Determine success() and error(): arguments 2-3. 249 var i; 250 for (i = 1; i < args.length; i++) { 251 if (jQuery.type(args[i]) === 'function') { 252 if (options.success) { 253 options.error = args[i]; 254 } else { 255 options.success = args[i]; 256 } 257 } 258 } 259 260 return { 261 options: options 262 }; 263 } 264 265 /** 266 * Given an object containing information about a tag, determines whether 267 * or not we should treat a tag as a editabled block. 268 * 269 * Relying on `onlyeditables' property to determine whether or not a given 270 * tag is a block or an editable is unreliable since it is possible to have 271 * a block which only contains editables: 272 * 273 * { 274 * "tagname":"content", 275 * "editables":[{ 276 * "element":"GENTICS_EDITABLE_1234", 277 * "readonly":false, 278 * "partname":"editablepart" 279 * }], 280 * "element":"GENTICS_BLOCK_1234", 281 * "onlyeditables":true 282 * "tagname":"tagwitheditable" 283 * } 284 * 285 * In the above example, even though `onlyeditable' is true the tag is 286 * still a block, since the tag's element and the editable's element are 287 * not the same. 288 * 289 * @param {object} tag A object holding the sets of blocks and editables 290 * that belong to a tag. 291 * @return {boolean} True if the tag 292 */ 293 function isBlock(tag) { 294 if (!tag.editables || tag.editables.length > 1) { 295 return true; 296 } 297 return ( 298 (1 === tag.editables.length) 299 && 300 (tag.editables[0].element !== tag.element) 301 ); 302 } 303 304 /** 305 * Given a data object received from a REST API "/rest/page/render" 306 * call maps the blocks and editables into a list of each. 307 * 308 * The set of blocks and the set of editables that are returned are not 309 * mutually exclusive--if a tag is determined to be both an editable 310 * and a block, it will be included in both sets. 311 * 312 * @param {object} data 313 * @return {object<string, Array.<object>>} A map containing a set of 314 * editables and a set of 315 * blocks. 316 */ 317 function getEditablesAndBlocks(data) { 318 if (!data || !data.tags) { 319 return { 320 blocks: [], 321 editables: [] 322 }; 323 } 324 325 var tag; 326 var tags = data.tags; 327 var blocks = []; 328 var editables = []; 329 var i; 330 var j; 331 332 for (i = 0; i < tags.length; i++) { 333 tag = tags[i]; 334 if (tag.editables) { 335 for (j = 0; j < tag.editables.length; j++) { 336 tag.editables[j].tagname = tag.tagname; 337 } 338 editables = editables.concat(tag.editables); 339 } 340 if (isBlock(tag)) { 341 blocks.push(tag); 342 } 343 } 344 345 return { 346 blocks: blocks, 347 editables: editables 348 }; 349 } 350 351 /** 352 * Abstract class that is implemented by tag containers such as 353 * {@link PageAPI} or {@link TemplateAPI} 354 * 355 * @class 356 * @name TagContainerAPI 357 */ 358 GCN.TagContainerAPI = GCN.defineChainback({ 359 /** @lends TagContainerAPI */ 360 361 /** 362 * @private 363 * @type {object<number, string>} Hash, mapping tag ids to their 364 * corresponding names. 365 */ 366 _tagIdToNameMap: null, 367 368 /** 369 * @private 370 * @type {object<number, string>} Hash, mapping tag ids to their 371 * corresponding names for newly created 372 * tags. 373 */ 374 _createdTagIdToNameMap: {}, 375 376 /** 377 * @private 378 * @type {Array.<object>} A set of blocks that are are to be removed 379 * from this content object when saving it. 380 * This array is populated during the save 381 * process. It get filled just before 382 * persisting the data to the server, and gets 383 * emptied as soon as the save operation 384 * succeeds. 385 */ 386 _deletedBlocks: [], 387 388 /** 389 * @private 390 * @type {Array.<object>} A set of tags that are are to be removed from 391 * from this content object when it is saved. 392 */ 393 _deletedTags: [], 394 395 /** 396 * Searching for a tag of a given id from the object structure that is 397 * returned by the REST API would require O(N) time. This function, 398 * builds a hash that maps the tag id with its corresponding name, so 399 * that it can be mapped in O(1) time instead. 400 * 401 * @private 402 * @return {object<number,string>} A hash map where the key is the tag 403 * id, and the value is the tag name. 404 */ 405 '!_mapTagIdsToNames': function () { 406 var name; 407 var map = {}; 408 var tags = this._data.tags; 409 for (name in tags) { 410 if (tags.hasOwnProperty(name)) { 411 map[tags[name].id] = name; 412 } 413 } 414 return map; 415 }, 416 417 /** 418 * Retrieves data for a tag from the internal data object. 419 * 420 * @private 421 * @param {string} name The name of the tag. 422 * @return {!object} The tag data, or null if a there if no tag 423 * matching the given name. 424 */ 425 '!_getTagData': function (name) { 426 return (this._data.tags && this._data.tags[name]) || 427 (this._shadow.tags && this._shadow.tags[name]); 428 }, 429 430 /** 431 * Get the tag whose id is `id'. 432 * Builds the `_tagIdToNameMap' hash map if it doesn't already exist. 433 * 434 * @todo: Should we deprecate this? 435 * @private 436 * @param {number} id Id of tag to retrieve. 437 * @return {object} The tag's data. 438 */ 439 '!_getTagDataById': function (id) { 440 if (!this._tagIdToNameMap) { 441 this._tagIdToNameMap = this._mapTagIdsToNames(); 442 } 443 return this._getTagData(this._tagIdToNameMap[id] || 444 this._createdTagIdToNameMap[id]); 445 }, 446 447 /** 448 * Extracts the editables and blocks that have been rendered from the 449 * REST API render call's response data. 450 * 451 * @param {object} data The response object received from the 452 * renderTemplate() call. 453 * @return {object} An object containing two properties: an array of 454 * blocks, and an array of editables. 455 */ 456 '!_processRenderedTags': getEditablesAndBlocks, 457 458 // !!! 459 // WARNING adding to folder is neccessary as jsdoc will report a 460 // name confict otherwise 461 // !!! 462 /** 463 * Get this content object's node. 464 * 465 * @function 466 * @name node 467 * @memberOf TagContainerAPI 468 * @param {funtion(NodeAPI)=} success Optional callback to receive a 469 * {@link NodeAPI} object as the 470 * only argument. 471 * @param {function(GCNError):boolean=} error Optional custom error 472 * handler. 473 * @return {NodeAPI} This object's node. 474 */ 475 '!node': function (success, error) { 476 return this.folder().node(); 477 }, 478 479 /** 480 * Synchronizes the information about tags with the server. 481 * 482 * @private 483 * @param {function} callback A function that will be called after 484 * reloading the tags. 485 */ 486 '!_syncTags': function (callback) { 487 if (typeof callback !== 'function') { 488 callback = function () {}; 489 } 490 491 delete this._data.tags; 492 this._fetched = false; 493 this.tags(callback); 494 }, 495 496 // !!! 497 // WARNING adding to folder is neccessary as jsdoc will report a 498 // name confict otherwise 499 // !!! 500 /** 501 * Get this content object's parent folder. 502 * 503 * @function 504 * @name folder 505 * @memberOf TagContainerAPI 506 * @param {funtion(FolderAPI)=} 507 * success Optional callback to receive a {@link FolderAPI} 508 * object as the only argument. 509 * @param {function(GCNError):boolean=} 510 * error Optional custom error handler. 511 * @return {FolderAPI} This object's parent folder. 512 */ 513 '!folder': function (success, error) { 514 var id = this._fetched ? this.prop('folderId') : null; 515 return this._continue(GCN.FolderAPI, id, success, error); 516 }, 517 518 /** 519 * Gets a tag of the specified id, contained in this content object. 520 * 521 * @name tag 522 * @function 523 * @memberOf TagContainerAPI 524 * @param {number} id Id of tag to retrieve. 525 * @param {function} success 526 * @param {function} error 527 * @return TagAPI 528 */ 529 '!tag': function (id, success, error) { 530 return this._continue(GCN.TagAPI, id, success, error); 531 }, 532 533 /** 534 * Retrieves a collection of tags from this content object. 535 * 536 * @name tags 537 * @function 538 * @memberOf TagContainerAPI 539 * @param {object|string|number} settings (Optional) 540 * @param {function} success callback 541 * @param {function} error (Optional) 542 * @return TagContainerAPI 543 */ 544 '!tags': function () { 545 var args = Array.prototype.slice.call(arguments); 546 547 if (args.length === 0) { 548 return; 549 } 550 551 var i; 552 var j = args.length; 553 var filter = {}; 554 var filters; 555 var hasFilter = false; 556 var success; 557 var error; 558 559 // Determine `success', `error', `filter' 560 for (i = 0; i < j; ++i) { 561 switch (jQuery.type(args[i])) { 562 case 'function': 563 if (success) { 564 error = args[i]; 565 } else { 566 success = args[i]; 567 } 568 break; 569 case 'number': 570 case 'string': 571 filters = [args[i]]; 572 break; 573 case 'array': 574 filters = args[i]; 575 break; 576 } 577 } 578 579 if (jQuery.type(filters) === 'array') { 580 var k = filters.length; 581 while (k) { 582 filter[filters[--k]] = true; 583 } 584 hasFilter = true; 585 } 586 587 var that = this; 588 589 if (success) { 590 this._read(function () { 591 var tags = that._data.tags; 592 var tag; 593 var list = []; 594 595 for (tag in tags) { 596 if (tags.hasOwnProperty(tag)) { 597 if (!hasFilter || filter[tag]) { 598 list.push(that._continue(GCN.TagAPI, tags[tag], 599 null, error)); 600 } 601 } 602 } 603 604 that._invoke(success, [list]); 605 }, error); 606 } 607 }, 608 609 /** 610 * Internal method to create a tag of a given tagtype in this content 611 * object. 612 * 613 * Not all tag containers allow for new tags to be created on them, 614 * therefore this method will only be surfaced by tag containers which 615 * do allow this. 616 * 617 * @private 618 * @param {string|number|object} construct either the keyword of the 619 * construct, or the ID of the construct 620 * or an object with the following 621 * properties 622 * <ul> 623 * <li><i>keyword</i> keyword of the construct</li> 624 * <li><i>constructId</i> ID of the construct</li> 625 * <li><i>magicValue</i> magic value to be filled into the tag</li> 626 * <li><i>sourcePageId</i> source page id</li> 627 * <li><i>sourceTagname</i> source tag name</li> 628 * </ul> 629 * @param {function(TagAPI)=} success Optional callback that will 630 * receive the newly created tag as 631 * its only argument. 632 * @param {function(GCNError):boolean=} error Optional custom error 633 * handler. 634 * @return {TagAPI} The newly created tag. 635 */ 636 '!_createTag': function () { 637 var args = parseCreateTagArguments(arguments); 638 639 if (args.error) { 640 GCN.handleError( 641 GCN.createError('INVALID_ARGUMENTS', args.error, arguments), 642 args.error 643 ); 644 return; 645 } 646 647 var obj = this; 648 649 // We use a uniqueId to avoid a fetus being created. 650 // This is to avoid the following scenario: 651 // 652 // var tag1 = container.createTag(...); 653 // var tag2 = container.createTag(...); 654 // tag1 === tag2 // is true which is wrong 655 // 656 // However, for all other cases, where we get an existing object, 657 // we want this behaviour: 658 // 659 // var folder1 = page(1).folder(...); 660 // var folder2 = page(1).folder(...); 661 // folder1 === folder2 // is true which is correct 662 // 663 // So, createTag() is different from other chainback methods in 664 // that each invokation must create a new instance, while other 665 // chainback methods must return the same. 666 // 667 // The id will be reset as soon as the tag object is realized. 668 // This happens below as soon as we get a success response with the 669 // correct tag id. 670 var newId = GCN.uniqueId('TagApi-unique-'); 671 672 // Create a new TagAPI instance linked to this tag container. Also 673 // acquire a lock on the newly created tag object so that any 674 // further operations on it will be queued until the tag object is 675 // fully realized. 676 var tag = obj._continue(GCN.TagAPI, newId)._procure(); 677 678 var options = args.options; 679 var copying = !!(options.sourcePageId && options.sourceTagname); 680 681 var onCopy = function () { 682 if (options.success) { 683 // When the newly created tag is a copy of another tag 684 // which itselfs contains nested tags, these nested 685 // tags were created in the CMS but this object would 686 // only know about the containing tag. 687 obj._syncTags(function() { 688 // update the tag with the synchronized data 689 tag._data = obj._data.tags[tag._name]; 690 obj._invoke(options.success, [tag]); 691 tag._vacate(); 692 }); 693 } else { 694 tag._vacate(); 695 } 696 }; 697 var onCreate = function () { 698 if (options.success) { 699 obj._invoke(options.success, [tag]); 700 } 701 tag._vacate(); 702 }; 703 704 if (copying) { 705 newTag(tag, { 706 copyPageId: options.sourcePageId, 707 copyTagname: options.sourceTagname 708 }, onCopy, options.error); 709 } else { 710 if (options.constructId) { 711 newTag(tag, { 712 magicValue: options.magicValue, 713 constructId: options.constructId 714 }, onCreate, options.error); 715 } else { 716 // ASSERT(options.keyword) 717 getConstruct(options.keyword, obj.node(), function (construct) { 718 newTag(tag, { 719 magicValue: options.magicValue, 720 constructId: construct.constructId 721 }, onCreate, options.error); 722 }, options.error); 723 } 724 } 725 726 return tag; 727 }, 728 729 /** 730 * Internal method to create multiple tags at once. 731 * The tagData object must have a property "create" that contains a single property for each tag to be created. Each property contains 732 * the request "data" (consisting of constructId/keyword and magicvalue) 733 * 734 * Each tag property will get the response object for that tag attached (when the request is successfull) 735 * The tagData object itself will get the whole response attached 736 * 737 * @private 738 * @param {object} tagData tag data object. 739 * @param {function(TagAPI)=} success Optional callback success callback 740 * @param {function(GCNError):boolean=} error Optional custom error 741 * handler. 742 */ 743 '!_createTags': function (tagData, success, error) { 744 var obj = this, id, newId; 745 746 for (id in tagData.create) { 747 if (tagData.create.hasOwnProperty(id)) { 748 newId = GCN.uniqueId('TagApi-unique-'); 749 tagData.create[id].tag = obj._continue(GCN.TagAPI, newId); 750 } 751 } 752 753 newTags(obj, tagData, success, error); 754 }, 755 756 /** 757 * Internal helper method to handle the create tag response. 758 * 759 * @private 760 * @param {TagAPI} tag 761 * @param {object} response response object from the REST call 762 * @param {function(TagContainerAPI)=} success optional success handler 763 * @param {function(GCNError):boolean=} error optional error handler 764 */ 765 '!_handleCreateTagResponse': function (tag, response, success, error) { 766 var obj = this; 767 768 if (GCN.getResponseCode(response) === 'OK') { 769 var data = response.tag; 770 tag._name = data.name; 771 tag._data = data; 772 tag._fetched = true; 773 774 // The tag's id is still the temporary unique id that was given 775 // to it in _createTag(). We have to realize the tag so that 776 // it gets the correct id. The new id changes its hash, so it 777 // must also be removed and reinserted from the caches. 778 tag._removeFromTempCache(tag); 779 tag._setHash(data.id)._addToCache(); 780 781 // Add this tag into the tag's container `_shadow' object, and 782 // `_tagIdToNameMap hash'. 783 var shouldCreateObjectIfUndefined = true; 784 obj._update('tags.' + GCN.escapePropertyName(data.name), 785 data, error, shouldCreateObjectIfUndefined); 786 787 // TODO: We need to store the tag inside the `_data' object for 788 // now. A change should be made so that when containers are 789 // saved, the data in the `_shadow' object is properly 790 // transfered into the _data object. 791 obj._data.tags[data.name] = data; 792 793 if (!obj.hasOwnProperty('_createdTagIdToNameMap')) { 794 obj._createdTagIdToNameMap = {}; 795 } 796 797 obj._createdTagIdToNameMap[data.id] = data.name; 798 799 tag.prop('active', true); 800 801 if (success) { 802 success(); 803 } 804 } else { 805 tag._die(GCN.getResponseCode(response)); 806 GCN.handleResponseError(response, error); 807 } 808 }, 809 810 /** 811 * Internal method to delete the specified tag from this content 812 * object. 813 * 814 * @private 815 * @param {string} keyword The keyword of the tag to be deleted. 816 * @param {function(TagContainerAPI)=} success Optional callback that 817 * receive this object as 818 * its only argument. 819 * @param {function(GCNError):boolean=} error Optional custom error 820 * handler. 821 */ 822 '!_removeTag': function (keyword, success, error) { 823 this.tag(keyword).remove(success, error); 824 }, 825 826 /** 827 * Internal method to delete a set of tags from this content object. 828 * 829 * @private 830 * @param {Array.<string>} keywords The keywords of the set of tags to be 831 * deleted. 832 * @param {function(TagContainerAPI)=} success Optional callback that 833 * receive this object as 834 * its only argument. 835 * @param {function(GCNError):boolean=} error Optional custom error 836 * handler. 837 */ 838 '!_removeTags': function (keywords, success, error) { 839 var that = this; 840 this.tags(keywords, function (tags) { 841 var j = tags.length; 842 while (j--) { 843 tags[j].remove(null, error); 844 } 845 if (success) { 846 that.save(success, error); 847 } 848 }, error); 849 } 850 851 }); 852 853 GCN.TagContainerAPI.hasTagData = hasTagData; 854 GCN.TagContainerAPI.extendTags = extendTags; 855 GCN.TagContainerAPI.getEditablesAndBlocks = getEditablesAndBlocks; 856 857 }(GCN));