1/* 2 * Script from NETTUTS.com [by James Padolsey] 3 * @requires jQuery($), jQuery UI & sortable/draggable UI modules 4 */ 5 6var iNettuts = { 7 8 jQuery : $, 9 10 settings : { 11 columns : '.column', 12 widgetSelector: '.widget', 13 handleSelector: '.widget-head', 14 contentSelector: '.widget-content', 15 widgetDefault : { 16 movable: true, 17 removable: false, 18 collapsible: true, 19 editable: false, 20 colorClasses : ['color-yellow', 'color-red', 'color-blue', 'color-white', 'color-orange', 'color-green'] 21 }, 22 widgetIndividual : { 23 intro : { 24 movable: false, 25 removable: true, 26 collapsible: false, 27 editable: false 28 }, 29 ad : { 30 movable: false, 31 removable: false, 32 collapsible: false, 33 editable: false 34 } 35 36 } 37 }, 38 39 init : function () { 40 this.attachStylesheet('vicjs/dragdrop/inettuts.js.css'); 41 this.addWidgetControls(); 42 this.makeSortable(); 43 }, 44 45 getWidgetSettings : function (id) { 46 var $ = this.jQuery, 47 settings = this.settings; 48 return (id&&settings.widgetIndividual[id]) ? $.extend({},settings.widgetDefault,settings.widgetIndividual[id]) : settings.widgetDefault; 49 }, 50 51 addWidgetControls : function () { 52 var iNettuts = this, 53 $ = this.jQuery, 54 settings = this.settings; 55 56 $(settings.widgetSelector, $(settings.columns)).each(function () { 57 var thisWidgetSettings = iNettuts.getWidgetSettings(this.id); 58 if (thisWidgetSettings.removable) { 59 $('<a href="#" class="remove">CLOSE</a>').mousedown(function (e) { 60 e.stopPropagation(); 61 }).click(function () { 62 if(confirm('This widget will be removed, ok?')) { 63 $(this).parents(settings.widgetSelector).animate({ 64 opacity: 0 65 },function () { 66 $(this).wrap('<div/>').parent().slideUp(function () { 67 $(this).remove(); 68 }); 69 }); 70 } 71 return false; 72 }).appendTo($(settings.handleSelector, this)); 73 } 74 75 if (thisWidgetSettings.editable) { 76 $('<a href="#" class="edit">EDIT</a>').mousedown(function (e) { 77 e.stopPropagation(); 78 }).toggle(function () { 79 $(this).css({backgroundPosition: '-66px 0', width: '55px'}) 80 .parents(settings.widgetSelector) 81 .find('.edit-box').show().find('input').focus(); 82 return false; 83 },function () { 84 $(this).css({backgroundPosition: '', width: ''}) 85 .parents(settings.widgetSelector) 86 .find('.edit-box').hide(); 87 return false; 88 }).appendTo($(settings.handleSelector,this)); 89 $('<div class="edit-box" style="display:none;"/>') 90 .append('<ul><li class="item"><label>Change the title?</label><input value="' + $('h3',this).text() + '"/></li>') 91 .append((function(){ 92 var colorList = '<li class="item"><label>Available colors:</label><ul class="colors">'; 93 $(thisWidgetSettings.colorClasses).each(function () { 94 colorList += '<li class="' + this + '"/>'; 95 }); 96 return colorList + '</ul>'; 97 })()) 98 .append('</ul>') 99 .insertAfter($(settings.handleSelector,this)); 100 } 101 102 if (thisWidgetSettings.collapsible) { 103 $('<a href="#" class="collapse">COLLAPSE</a>').mousedown(function (e) { 104 e.stopPropagation(); 105 }).toggle(function () { 106 $(this).css({backgroundPosition: '-38px 0'}) 107 .parents(settings.widgetSelector) 108 .find(settings.contentSelector).hide(); 109 slaOp(); 110 return false; 111 },function () { 112 $(this).css({backgroundPosition: '-52px 0'}) 113 .parents(settings.widgetSelector) 114 .find(settings.contentSelector).show(); 115 slaOp(); 116 return false; 117 }
117).prependTo($(settings.handleSelector,this)); 118 } 119 }); 120 121 $('.edit-box').each(function () { 122 $('input',this).keyup(function () { 123 $(this).parents(settings.widgetSelector).find('h3').text( $(this).val().length>20 ? $(this).val().substr(0,20)+'...' : $(this).val() ); 124 }); 125 $('ul.colors li',this).click(function () { 126 127 var colorStylePattern = /\bcolor-[\w]{1,}\b/, 128 thisWidgetColorClass = $(this).parents(settings.widgetSelector).attr('class').match(colorStylePattern) 129 if (thisWidgetColorClass) { 130 $(this).parents(settings.widgetSelector) 131 .removeClass(thisWidgetColorClass[0]) 132 .addClass($(this).attr('class').match(colorStylePattern)[0]); 133 } 134 return false; 135 136 }); 137 }); 138 139 }, 140 141 attachStylesheet : function (href) { 142 var $ = this.jQuery; 143 return $('<link href="' + href + '" rel="stylesheet" type="text/css" />').appendTo('head'); 144 }, 145 146 makeSortable : function () { 147 var iNettuts = this, 148 $ = this.jQuery, 149 settings = this.settings, 150 $sortableItems = (function () { 151 var notSortable = ''; 152 $(settings.widgetSelector,$(settings.columns)).each(function (i) { 153 if (!iNettuts.getWidgetSettings(this.id).movable) { 154 if(!this.id) { 155 this.id = 'widget-no-id-' + i; 156 } 157 notSortable += '#' + this.id + ','; 158 } 159 }); 160 return $('> li:not(' + notSortable + ')', settings.columns); 161 })(); 162 163 $sortableItems.find(settings.handleSelector).css({ 164 cursor: 'move' 165 }).mousedown(function (e) { 166 $sortableItems.css({width:''}); 167 $(this).parent().css({ 168 width: $(this).parent().width() + 'px' 169 }); 170 }).mouseup(function () { 171 if(!$(this).parent().hasClass('dragging')) { 172 $(this).parent().css({width:''}); 173 } else { 174 $(settings.columns).sortable('disable'); 175 } 176 }); 177 178 $(settings.columns).sortable({ 179 items: $sortableItems, 180 connectWith: $(settings.columns), 181 handle: settings.handleSelector, 182 placeholder: 'widget-placeholder', 183 forcePlaceholderSize: true, 184 revert: 300, 185 delay: 100, 186 opacity: 0.7, 187 containment: 'document', 188 start: function (e,ui) { 189 $(ui.helper).addClass('dragging'); 190 }, 191 stop: function (e,ui) { 192 $(ui.item).css({width:''}).removeClass('dragging'); 193 $(settings.columns).sortable('enable'); 194 slaOp(); 195 } 196 }); 197 } 198 199}; 200 201function createCookie(name,value,days) { 202 if (days) { 203 var date = new Date(); 204 date.setTime(date.getTime()+(days*24*60*60*1000)); 205 var expires = "; expires="+date.toGMTString(); 206 } 207 else var expires = ""; 208 document.cookie = name+"="+value+expires+"; path=/"; 209} 210 211function readCookie(name) { 212 var nameEQ = name + "="; 213 var ca = document.cookie.split(';'); 214 for(var i=0;i < ca.length;i++) { 215 var c = ca[i]; 216 while (c.charAt(0)==' ') c = c.substring(1,c.length); 217 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 218 } 219 return null; 220} 221 222function eraseCookie(name) { 223 createCookie(name,"",-1); 224} 225 226 227// Vicfunctions 228function slaOp(){ 229if (nogBezigMetInitializeren){return true;} 230 231 232// NIEUW 233i=0; 234$('.widget-content').each(function(){ 235if (!$(this).html().match('googleads')){ 236if (i%2){ 237$(this).css('background-color','#DFDFDF'); 238}else{ 239$(this).css('background-color','#FFFFDE'); 240} 241i++; 242}}); 243 244// NIEUW 245 246a = document.getElementsByTagName('div'); 247result = ''; 248for (b=0;b<a.length;b++){ 249if (a[b].className=='widget-head'){ 250state = a[b+1].style.display ? 'ingeklapt' : 'uitgeklapt'; 251if (a[b+1].style.display.toLowerCase()=='block'){state='uitgeklapt';} 252result+='{'+a[b].getElementsByTagName('a')[1].innerHTML+'|'+state+'}'; 253}} 254result+=''; 255 256cookie = readCookie('krantenVolgorde'+krantenChannel); 257if(!cookie){ 258 var dateObject = new Date(); 259 var code = 260 dateObject.getFullYear() + '' + 261 dateObject.getMonth() + '' + 262 dateObject.getDate() + '' + 263 dateObject.getTime(); 264 createCookie('krantenVolgorde'+krantenChannel,code,3000); 265 }else{ 266 code = cookie; 267} 268 269$.ajax({ url: "xmlrequests.php?code="+code+"&state="+result+"&c="+krantenChannel, success: function(){ 270 $(this).addClass("done"); 271 }}); 272} 273iNettuts.init();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.